package cn.snmp.mutual.uk.stack;

import java.util.*;
import java.io.*;

class AsnEncoderBase {
    private static final String version_id = "@(#)$Id: AsnEncoderBase.java,v 3.2 2006/01/17 17:43:53 birgit Exp $ Copyright Westhawk Ltd";

    protected AsnObject EncodePdu(final byte msg_type, final int pduId, final int errstat, final int errind, final Enumeration ve) throws IOException {
        final AsnObject asnPduObject = new AsnSequence(msg_type);
        asnPduObject.add(new AsnInteger(pduId));
        asnPduObject.add(new AsnInteger(errstat));
        asnPduObject.add(new AsnInteger(errind));
        final AsnObject asnVBLObject = asnPduObject.add(new AsnSequence());
        while (ve.hasMoreElements()) {
            final AsnObject asnVBObject = asnVBLObject.add(new AsnSequence());
            final Varbind vb = (Varbind) ve.nextElement();
            asnVBObject.add(vb.getOid());
            asnVBObject.add(vb.getValue());
        }
        return asnPduObject;
    }
}
